﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using snat.algorithms;
using System.ComponentModel;
using snat.model;

namespace gui {

    /// <summary>
    /// GUI Notifiable FactoryItem Class
    /// Factory Item holds an INodeFactory, a selected boolean
    /// and an enabled boolean property
    /// </summary>
    public class FactoryItem : INotifyPropertyChanged {

        private bool selected;
        public bool Selected {
            get { return selected; }
            set {
                if (selected == value) return;
                selected = value;
                if (null != this.PropertyChanged) {
                    PropertyChanged(this, new PropertyChangedEventArgs("Selected"));
                }
            }
        }

        private bool enabled;
        public bool Enabled {
            get { return enabled; }
            set {
                if (enabled == value) return;
                enabled = value;
                if (null != this.PropertyChanged) {
                    PropertyChanged(this, new PropertyChangedEventArgs("Enabled"));
                }
            }
        }

        public string Name { get; private set; }
        public INodeFactory Factory { get; private set; }

        public FactoryItem(INodeFactory f, string name) {
            Factory = f;
            Name = name;
            Selected = false;
            Enabled = false;
        }

        public FactoryItem(INodeFactory f, string name, bool defaultSelection) {
            Factory = f;
            Name = name;
            Selected = defaultSelection;
            Enabled = false;
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
